package com.company.observer.mode;

import com.company.observer.listener.McListener;
import com.company.observer.listener.MessageListener;
import com.company.observer.listener.message.EventManager;

/**
 * @Author : hxma@easipass.com
 * @Date : 2021/5/11
 **/
public abstract class LotteryService {
    EventManager eventManager;

    public LotteryService() {
        eventManager = new EventManager(EventManager.EnumType.MESSAGE, EventManager.EnumType.MQ);
        eventManager.subscribe(EventManager.EnumType.MESSAGE,new MessageListener());
        eventManager.subscribe(EventManager.EnumType.MQ,new McListener());
    }
    public void draw(String uid){
        Result result = doDraw(uid);
        eventManager.notifyMessage(EventManager.EnumType.MESSAGE,result);
        eventManager.notifyMessage(EventManager.EnumType.MQ,result);
    }

    protected abstract Result doDraw(String uid);

}
